//2009/08/24 20:02:39
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#include <sstream>
#include <algorithm>

using namespace std;

class PirateTreasure
{
public:
    double getDistance(vector <int> steps, vector <string> directions)
    {
		double x = 0;
		double y = 0;
		for(int i=0; i<steps.size(); i++)
		{
			if(directions[i] == "NORTH") y += steps[i];
			else if(directions[i] == "SOUTH") y -= steps[i];
			else if(directions[i] == "EAST") x += steps[i];
			else if(directions[i] == "WEST") x -= steps[i];
			else if(directions[i] == "NORTHWEST") 
			{
				double temp = 1.0 * steps[i] / sqrt(2.0);
				x -= temp;
				y += temp;
			}
			else if(directions[i] == "NORTHEAST") 
			{
				double temp = 1.0 * steps[i] / sqrt(2.0);
				x += temp;
				y += temp;
			}
			else if(directions[i] == "SOUTHEAST")
			{
				double temp = 1.0 * steps[i] / sqrt(2.0);
				x += temp;
				y -= temp;
			}
			else if(directions[i] == "SOUTHWEST")  
			{
				double temp = 1.0 * steps[i] / sqrt(2.0);
				x -= temp;
				y -= temp;
			}
		}
		return sqrt(x*x + y*y);
    }
};
